package com.it.xiaotao.mode.policy;

import java.util.HashMap;
import java.util.Map;

public class CarPolicy {
    private Map<String, Car> carMap = new HashMap<>();

    public CarPolicy() {
        carMap.put("baoma", new BaoMa());
        carMap.put("benchi", new BenChi());
        carMap.put("bentian", new Car() {
            @Override
            public void run() {
                System.out.println("本田时速220km/h");
            }
        });
    }

    public void run(String type) {
        carMap.get(type).run();
    }
}
